﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = null;
}
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/js/js.cookie.js"></script>
<script src="~/js/moment.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>修改生产领料单</title>
    <link href="//unpkg.com/layui@2.9.21-rc/dist/css/layui.css" rel="stylesheet">
</head>
<body>
    <h2>修改生产领料单</h2>
    <br />
    <br />
    <form>
        <!-- 文本框 领料单编号 -->
        <div class="layui-form-item">
            <label class="layui-form-label"><span style="color:red">*</span><b>领料单编号</b></label>
            <div class="layui-input-inline">
                <input style="width:190px" type="text" id="pickingNode" name="pickingNode" lay-verify="required" placeholder="请输入领料单编号" autocomplete="off" class="layui-input">
                <div class="layui-input-suffix">
                    <div class="layui-input-inline">
                        <div class="layui-input-group">
                            <button style="left:30px" type="button" class="layui-btn layui-btn-primary layui-btn-xs" onclick="pinkAlls()">自动生成</button>
                        </div>
                    </div>
                </div>
            </div>
            <!-- 文本框 领料单名称 -->
            <label style="left:70px" class="layui-form-label"><span style="color:red">*</span><b>领料单名称</b></label>
            <div class="layui-input-inline" style="left:80px;width:500px">
                <input type="text" id="pickingName" name="pickingName" lay-verify="required" placeholder="请输入领料单名称" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <!-- 领料日期 -->
            <label class="layui-form-label"><span style="color:red">*</span><b>领料日期</b></label>
            <div class="layui-input-inline">
                @* <input type="text" name="pickingTime" class="layui-input" id="ID-laydate-type-datetime"  > *@
                <input type="text" name="pickingTime" id="ID-laydate-type-datetime" lay-verify="date" autocomplete="off" class="layui-input">
            </div>

            <!-- 生产工单 -->
            <label class="layui-form-label"><span style="color:red">*</span><b>生产工单</b></label>
            <div class="layui-input-group">
                <input type="text" id="productionWorkOrdersNo" name="ProductionWorkOrdersNo" placeholder="请选择生产工单" class="layui-input">
                <div class="layui-input-split layui-input-suffix" style="cursor: pointer;">
                    <i class="layui-icon layui-icon-search" lay-on="test-page"></i>
                </div>
            </div>

            <!-- 工作站 -->
            <label class="layui-form-label"><span style="color:red">*</span><b>工作站</b></label>
            <div class="layui-input-group">
                <input type="text" id="workStations" name="workStations" placeholder="请选择工作站" class="layui-input">
                @*  <div class="layui-input-split layui-input-suffix" style="cursor: pointer;">
                <i class="layui-icon layui-icon-search" lay-on="test-iframe-Client"></i>
                </div> *@
            </div>
        </div>

        <div class="layui-form-item">
            <!-- 工作站名称 -->
            <label style="right:2.5px" class="layui-form-label"><b>工作站名称</b></label>
            <div class="layui-input-inline" style="right:0.5px">
                <input type="text" id="workStationName" name="workStationName" lay-verify="required" placeholder="请选择工作站名称" autocomplete="off" class="layui-input">
            </div>
            <!-- 客户编号 -->
            <label style="left:70px" class="layui-form-label"><b>客户编号</b></label>
            <div class="layui-input-inline" style="left:80px">
                <input type="text" id="clientNo" name="clientNo" lay-verify="required" placeholder="请选择客户编号" autocomplete="off" class="layui-input">
            </div>
            <!-- 客户名称 -->
            <label style="left:70px" class="layui-form-label"><b>客户名称</b></label>
            <div class="layui-input-inline" style="left:80px">
                <input type="text" id="clientName" name="clientName" lay-verify="required" placeholder="请选择客户名称" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <!-- 备注 -->
            <label style="right:10px" class="layui-form-label"><b>备注</b></label>
            <div class="layui-input-inline" style="left:0.3px;width:890px">
                <textarea name="remark" id="remark" placeholder="请输入内容" class="layui-textarea"></textarea>
            </div>
        </div>

        <!-- 按钮 -->
        <div class="layui-form-item" style="left:860px">
            <div class="layui-btn-container">
                <button type="button" class="layui-btn layui-bg-blue" lay-submit lay-filter="demo1">确定</button>
                <button type="button" class="layui-btn ">取消</button>
            </div>
        </div>
    </form>

    <!-- 反填 生产工单 客户编号 客户名称 -->
    <script type="text/html" id="toolDemo">
        <div class="layui-clear-space">
            <a style="color:cornflowerblue" lay-event="delect" onclick="AddThis(productionWorkOrdersNo,clientNo,clientName)">选择</a>
        </div>
    </script>

    <br />
    <br />
    <div style="left:500px"><h3> ------------------------------------------------------------------------------------------------------  物料信息  ------------------------------------------------------------------------------------------------------</h3></div>
    <div class="layui-panel">
        <br />
        <!-- 按钮: 新增 修改 删除 -->
        <div>
            <button class="layui-btn layui-btn-primary layui-border-blue" onclick="addes()">+新增</button>
            <button class="layui-btn layui-btn-primary layui-border-green">修改</button>
            <button class="layui-btn layui-btn-primary layui-border-red">删除</button>
        </div>
        <!-- 表格 -->
        <div style="padding: 32px;">
            <table class="layui-table">
                <colgroup>
                    <col width="150">
                    <col width="150">
                    <col width="150">
                    <col width="150">
                    <col width="150">
                    <col width="150">
                    <col width="150">
                    <col width="150">
                    <col width="150">
                    <col>
                </colgroup>
                <thead>
                    <tr>
                        <th style="text-align:center">产品物料编码</th>
                        <th style="text-align:center">产品物料名称</th>
                        <th style="text-align:center">规格型号</th>
                        <th style="text-align:center">单位</th>
                        <th style="text-align:center">领料数量</th>
                        <th style="text-align:center">批次号</th>
                        <th style="text-align:center">仓库名称</th>
                        <th style="text-align:center">备注</th>
                    </tr>
                </thead>
                <tbody style="text-align:center">
                </tbody>
            </table>
            <div id="demo-laypage-all"></div>
        </div>
    </div>

    <!-- HTML Content -->
    <script src="//unpkg.com/layui@2.9.21-rc/dist/layui.js"></script>
    <script>
        var form = layui.form;
        layui.use(['form', 'laydate', 'util'], function () {
            var form = layui.form;
            // var laypage = layui.laypage;
            var layer = layui.layer;
            var $ = layui.$;
            var laydate = layui.laydate;
            var table = layui.table;
            var util = layui.util;
            var pageIndex = 1;
            var pageSize = 2;

            //就绪函数
            $(function () {

                PickingEdit();
            })

            //生产工单
            util.on('lay-on', {
                'test-page': function () {
                    layer.open({
                        type: 1,
                        area: '100%',
                        resize: false,
                        shadeClose: true,
                        title: '生产工单',
                        // area: ['420px', '240px'], // 宽高
                        content: `
                        <form class="layui-form layui-row layui-col-space16">
                                <div class="layui-col-xs4">
                                    <div class="layui-input-group">
                                        <div class="layui-input-prefix"><b>工单编码:</b> </div>
                                        <input type="text" id="ProductionWorkOrdersNoSe" value="" placeholder="请输入工单编码" class="layui-input" lay-affix="clear">
                                    </div>
                                </div>
                                <div class="layui-col-xs4">
                                    <div class="layui-input-group">
                                        <div class="layui-input-prefix"><b>工单名称:</b> </div>
                                        <input type="text" id="ProductionWorkOrdersNameSe" placeholder="请输入工单名称" lay-affix="clear" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-col-xs3">
                                    <div class="layui-input-group">
                                        <div class="layui-input-prefix"><b>来源单据:</b> </div>
                                        <div class="layui-input-inline">
                                            <input type="radio" lay-filter="demo-radio-filter" name="SourceSe" value="" title="全部" checked>
                                            <input type="radio" lay-filter="demo-radio-filter" name="SourceSe" value="客户订单" title="客户订单">
                                            <input type="radio" lay-filter="demo-radio-filter" name="SourceSe" value="库存备货" title="库存备货">
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <div class="layui-input-group">
                                        <div class="layui-input-prefix"><b>产品编号:</b> </div>
                                        <input type="text" id="ProductsNoSe" placeholder="请输入产品编号" lay-affix="clear" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <div class="layui-input-group">
                                        <div class="layui-input-prefix"><b>产品名称:</b> </div>
                                        <input type="text" id="ProductsNameSe" placeholder="请输入产品名称" lay-affix="clear" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-col-md4">
                                    <div class="layui-input-group">
                                        <div class="layui-input-prefix"><b>客户编码:</b> </div>
                                        <input type="text" id="ClientNoSe" placeholder="请输入客户编码" lay-affix="clear" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-col-xs4">
                                    <div class="layui-input-group">
                                        <div class="layui-input-prefix"><b>客户名称:</b> </div>
                                        <input type="text" id="ClientNameSe" placeholder="请输入客户名称" lay-affix="clear" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-col-xs4">
                                    <div class="layui-input-group">
                                        <div class="layui-input-prefix"><b>工单类型:</b> </div>
                                        <div class="layui-input-inline">
                                            <select id="TicketsTypeSe" lay-filter="aihao">
                                                <option value=""></option>
                                                <option value="自产">自产</option>
                                                <option value="外协">外协</option>
                                                <option value="外购">外购</option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-xs4">
                                    <div class="layui-input-group">
                                        <div class="layui-input-prefix"><b>需求日期:</b> </div>
                                        <div class="layui-input-wrap">
                                            <div class="layui-input-prefix">
                                                <i class="layui-icon layui-icon-date"></i>
                                            </div>
                                            <input type="text" id="DemandDateSe" readonly placeholder="请选择需求日期" class="layui-input demo-table-search-date">
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-btn-container layui-col-xs12">
                                    <button class="layui-btn" lay-submit lay-filter="demo-table-search">查询</button>
                                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                                </div>
                            </form>
                                    <table class="layui-hide" id="ID-table-demo-search" lay-filter="ID-table-demo-search"></table>

                        <div id="demo-laypage-all"></div>
                        `,
                        //success
                        success: function () {
                            //列表显示
                            getTable(pageIndex, pageSize);
                            function getTable(pageIndex, pageSize) {
                                let dataObj = {
                                    productionWorkOrdersNo: $("#ProductionWorkOrdersNoSe").val(),
                                    productionWorkOrdersName: $("#ProductionWorkOrdersNameSe").val(),
                                    source: $("[name='SourceSe']:checked").val(),
                                    productsNo: $("#ProductsNoSe").val(),
                                    productsName: $("#ProductsNameSe").val(),
                                    clientNo: $("#ClientNoSe").val(),
                                    clientName: $("#ClientNameSe").val(),
                                    ticketsType: $("#TicketsTypeSe").val(),
                                    demandDate: $("#DemandDateSe").val() || null,
                                    pageIndex: pageIndex,
                                    pageSize: pageSize
                                }
                                // 创建表格实例
                                var inst = table.render({
                                    elem: '#ID-table-demo-search',
                                    method: 'POST',
                                    contentType: 'application/json',
                                    toolbar: '#toolbarDemo',
                                    defaultToolbar: ['filter', 'exports', 'print', { // 右上角工具图标
                                        title: '提示',
                                        layEvent: 'LAYTABLE_TIPS',
                                        icon: 'layui-icon-tips',
                                        onClick: function (obj) { // 2.9.12+
                                            layer.alert('自定义工具栏图标按钮');
                                        }
                                    }],
                                    url: '@ViewBag.FoundationRead' + '/api/WorkOrders/PageProductionList', // 此处为静态模拟数据，实际使用时需换成真实接口
                                    where: dataObj,
                                    cols: [[
                                        { field: 'productionWorkOrdersNo', title: '工单编码', width: 120, sort: true, fixed: true },
                                        { field: 'productionWorkOrdersName', title: '工单名称', width: 120 },
                                        { field: 'ticketsType', title: '工单类型', width: 100 },
                                        { field: 'source', title: '工单来源', width: 100 },
                                        { field: 'orderNumber', title: '订单编号', width: 100 },
                                        { field: 'productManageNode', title: '产品编号', width: 100 },
                                        { field: 'productManageName', title: '产品名称', width: 100 },
                                        { field: 'productManageNumber', title: '规格型号', width: 100 },
                                        { field: 'unites', title: '单位', width: 80 },
                                        { field: 'ticketsNum', title: '工单数量', width: 100 },
                                        { field: 'adjustNum', title: '调整数量', width: 100 },
                                        { field: 'proNum', title: '以生产数量', width: 100 },
                                        { field: 'batchNo', title: '批次号', width: 100 },
                                        { field: 'clientNo', title: '客户编码', width: 100 },
                                        { field: 'clientName', title: '客户名称', width: 100 },
                                        { field: 'demandDates', title: '需求日期', width: 100 },
                                        { field: 'state', title: '单据状态', width: 100 },
                                        {
                                            fixed: 'right', title: '操作', width: 140, minWidth: 140, templet: function (d) {
                                                // d 是当前行的数据对象
                                                // 返回一个 HTML 字符串，包含按钮
                                                // return `<button class="btn btn-primary get-value-btn"  onclick="AddThis(${d.productionWorkOrdersNo},${d.clientNo},${d.clientName})">选择</button>`;
                                                return `<button class="btn btn-primary get-value-btn" onclick="AddThis('${d.productionWorkOrdersNo}', '${d.clientNo}', '${d.clientName}')">选择</button>`;

                                                // 上面的代码中，我们使用了 .replace(/'/g, "\\'") 来转义单引号，
                                                // 这是因为在 onclick 属性中，单引号可能会被解释为字符串的结束符，
                                                // 导致 JavaScript 代码出错。然而，这种方法并不完美，因为它只处理了单引号，
                                                // 并且没有处理其他可能破坏 HTML 或 JavaScript 的特殊字符。

                                                // 更安全的做法是使用一个更全面的转义函数，或者完全避免在 HTML 中写 JavaScript 代码。
                                            }
                                        }
                                        // data-id="${d.productionWorkOrdersNo}"< td > <a onclick="GetClient(${this.clientId},'${this.clientNo}','${this.clientName}')" class= "btn btn-link" > 选择 < /a></td >
                                    ]],
                                    page: false,
                                    height: 310,
                                    done: function (res) {
                                        var id = this.id;
                                        console.log(res);// 你可以在这里检查返回的数据结构是否符合预期
                                        // 触发单元格工具事件
                                        //分页数据
                                        laypage.render({
                                            elem: 'demo-laypage-all', // 元素 id
                                            count: res.totalCount, // 数据总数
                                            curr: pageIndex,
                                            limit: pageSize,
                                            limits: [2, 3, 4],
                                            layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip'], // 功能布局
                                            jump: function (obj, first) {
                                                if (!first) {
                                                    getTable(obj.curr, obj.limit);
                                                }
                                            }
                                        });
                                    }
                                });
                            }
                        }
                    });
                },

                //工作站
                // 'test-iframe-Client': function () {
                //     layer.open({
                //         type: 1,
                //         area: ['900px', '600px'],
                //         resize: false,
                //         shadeClose: true,
                //         title: '',
                //         content: `

                //             `,
                //             //success
                //     })
                // }
            })

            // 日期时间选择器
            laydate.render({
                elem: '#ID-laydate-type-datetime'
            });
        });

        //自动生成 领料单编号
        function pinkAlls() {
            var datec = new Date()
            var year = datec.getFullYear();
            var month = (datec.getMonth() + 1).toString().padStart(2, "0")
            var date = (datec.getDate() + 1).toString().padStart(2, "0")
            var hours = datec.getHours()
            var minute = (datec.getMinutes()).toString().padStart(2, "0")
            var seconds = (datec.getSeconds()).toString().padStart(2, "0")
            // var Encoding = "IF";
            var result = "ISSUE" + year + month + date + hours + minute + seconds;
            console.log(result);
            $("#pickingNode").val(result);
        };

        //反填 生产工单 客户编号 客户名称
        function AddThis(number, val, name) {
            console.log(number, val, name)
            $("[name='ProductionWorkOrdersNo']").val(number);
            $("[name='clientNo']").val(val);
            $("[name='clientName']").val(name);
            // form.render();
            layer.close(layer.index); // 关闭当前最新弹层
        };

        //反填生产领料 数据
        var pickingId = location.href.split("=")[1];
        function PickingEdit() {
            let obj = {
                pickingId: pickingId
            }
            console.log(obj);
            $.ajax({
                url: '@ViewBag.FoundationWrite' + "/api/ProductType/PickingEdit",
                data: JSON.stringify(obj),
                type: "post",
                dataType: "json",
                contentType: "application/json",
                success: res => {
                    console.log(res.objects.pickingNode)
                    //反填表单数据
                    // $("[name='pickingId']").val(res.objects.pickingId);
                    $("[name='pickingNode']").val(res.objects.pickingNode);
                    $("[name='pickingName']").val(res.objects.pickingName);
                    $("[name='pickingTime']").val(res.objects.pickingTime.split("T")[0]); //日期反填
                    $("[name='ProductionWorkOrdersNo']").val(res.objects.productionWorkOrdersNo);
                    $("[name='workStations']").val(res.objects.workStations);
                    $("[name='workStationName']").val(res.objects.workStationName);
                    $("[name='clientNo']").val(res.objects.clientNo);
                    $("[name='clientName']").val(res.objects.clientName);
                    $("[name='remark']").val(res.objects.remark);
                    $("[name='documents']").val(res.objects.documents);

                    form.render(); //重新渲染
                }
            })
        }

        //生产领料 修改
        form.on('submit(demo1)', function (data) {
            var datas = {
                pickingId: pickingId,
                pickingNode: $("[name='pickingNode']").val(),  //领料单编号
                pickingName: $("[name='pickingName']").val(),  //领料单名称
                pickingTime: $("[name='pickingTime']").val(),  //领料单日期
                productionWorkOrdersNo: $("[name='ProductionWorkOrdersNo']").val(), //生产工单
                workStations: $("[name='workStations']").val(), //工作id
                workStationName: $("[name='workStationName']").val(), //工作站名称
                clientNo: $("[name='clientNo']").val(),     //客户编号
                clientName: $("[name='clientName']").val(), //客户名称
                remark: $("[name='remark']").val(), //备注
                documents: 1
            };
            console.log(datas);
            $.ajax({
                // url: "http://localhost:5292/api/ProductType/PickingUpdates",
                url: '@ViewBag.FoundationWrite' + "/api/ProductType/PickingUpdates",
                data: JSON.stringify(datas),
                type: "post",
                dataType: "json",
                contentType: "application/json",
                success: function (res) {
                    console.log(123, res);
                    if (res.code > 0) {
                        layer.alert("编辑成功", {
                            title: ''
                        });
                    }
                    else {
                        alert('编辑失败')
                    }
                }
            })
            //onclick="pinkAdd()"
            // layer.alert(JSON.stringify(field), {
            //     title: '当前填写的字段值'
            // });
            // 此处可执行 Ajax 等操作
            return false; // 阻止默认 form 跳转
        })

        //跳转 生产领料单行
        function addes() {
            layer.open({
                type: 2,
                title: '生产领料单行 新增',
                shadeClose: true,
                maxmin: true, //开启最大化最小化按钮
                area: ['100%', '100%'],
                content: '/Messages/PickingLineAdd',
            });
        }

        var $ = layui.$;
        var layer = layui.layer;
        var util = layui.util;
        var form = layui.form;
        //库存物资选择
        layui.use(function () {
            // 事件
            util.on('lay-on', {
                'test-page-customsed': function () {
                    layer.open({
                        type: 1,
                        area: '100%',
                        resize: false,
                        shadeClose: true,
                        title: '库存物资选择',
                        content: `
                        <form class="layui-form" action="">
                            <div class="layui-form" lay-filter="filter-test-layer" style="margin: 16px;">
                                <div class="layui-form-item">
                                    <div class="demo-Add-container">
                                        <table style="left:320px" class="layui-hide" id="ID-table-demo-datasd" lay-filter="ID-table-demo-datasd"></table>
                                    </div>
                                </div>
                            </div>
                        </form>
                        `,
                        success: function () {
                            var form = layui.form;
                            var laypage = layui.laypage;
                            var layer = layui.layer;
                            var $ = layui.$;
                            var laydate = layui.laydate;
                            var util = layui.util;

                            //文档就绪函数
                            $(function () {
                                ProductsSales(1, 2);
                            })


                            //生产报工列表
                            function ProductsSales(pageIndex, pageSize) {
                                let obj = {
                                    pageIndex: pageIndex,
                                    pageSize: pageSize
                                }
                                var inst = table.render({
                                    elem: '#ID-table-demo-datasd',
                                    method: 'post',
                                    contentType: 'application/json',
                                    toolbar: '#toolbarDemo',
                                    defaultToolbar: ['filter', 'exports', 'print', { // 右上角工具图标
                                        title: '提示',
                                        layEvent: 'LAYTABLE_TIPS',
                                        icon: 'layui-icon-tips',
                                        onClick: function (obj) { // 2.9.12+
                                            layer.alert('自定义工具栏图标按钮');
                                        }
                                    }],
                                    url: '@ViewBag.FoundationRead' + '/api/UserLi/SearchMaterial',
                                    where: obj,
                                    cols: [[
                                        { field: 'productManageNode', title: '产品物料编码', width: 120 },
                                        { field: 'productManageName', title: '产品物料名称', width: 120 },
                                        { field: 'ProductManageNumber', title: '规格型号', width: 120 },
                                        { field: 'unites', title: '单位', width: 120 },
                                        { field: 'batch', title: '入库批次号', width: 120 },
                                        { field: 'stashName', title: '仓库名称', width: 120 },
                                        { field: 'num', title: '在库数量', width: 80 },
                                        { field: 'materialTime', title: '库存有效期', width: 120 },
                                        { fixed: 'right', title: '操作', width: 140, minWidth: 140, templet: '#toolDemo' }
                                    ]],
                                    page: false,
                                    height: 310,
                                    done: function (res) {
                                        var id = this.id;
                                        console.log(res);// 你可以在这里检查返回的数据结构是否符合预期
                                        // 触发单元格工具事件
                                        //分页数据
                                        laypage.render({
                                            elem: 'demo-laypage-alles', // 元素 id
                                            count: res.totalCount, // 数据总数
                                            curr: pageIndex,
                                            limit: pageSize,
                                            limits: [2, 3, 4],
                                            layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip'], // 功能布局
                                            jump: function (obj, first) {
                                                if (!first) {
                                                    ProductionSearch(obj.curr, obj.limit);
                                                }
                                            }
                                        });
                                    }
                                })
                                table.on('tool(ID-table-demo-datasd)', function (obj) { // 双击 toolDouble
                                    var data = obj.data; // 获得当前行数据
                                    console.log(data)
                                    if (obj.event === 'YesWang') {
                                        $("#productManageNode").val(data.productManageNode);
                                        $("#productManageName").val(data.productManageName);
                                        $("#unites").val(data.unites);
                                        $("#productManageNumber").val(data.productManageNumber);
                                         $("#stashName").val(data.stashName);
                                        $("#Batch").val(data.batch);
                                        $("#Num").val(data.num);
                                        localStorage.setItem("materialNo", data.materialNo);
                                        localStorage.setItem("stashId", data.stashId);
                                        // 对弹层中的表单进行初始化渲染
                                        form.render();
                                        layer.close(layer.index); // 关闭弹层
                                    }
                                });
                            }


                            // 对弹层中的表单进行初始化渲染
                            form.render();
                            // 表单提交事件
                            form.on('submit(demo-Search)', function (data) {
                                var field = data.field; // 获取表单字段值

                                // 显示填写结果，仅作演示用
                                // layer.alert(JSON.stringify(field), {
                                //     title: '当前填写的字段值'
                                // });
                                // 此处可执行 Ajax 等操作
                                // …

                                return false; // 阻止默认 form 跳转
                            });
                        }
                    });
                }
            })
        });

        
    </script>
</body>
</html>
<script>
    //物料信息
    var form = layui.form;
    var laypage = layui.laypage;
    var layer = layui.layer;
    var $ = layui.$;
    var laydate = layui.laydate;
    var util = layui.util;
    //分页
    var pageIndex = 1;
    var pageSize = 2;
    var pickingNode = "";

    $(function () {
        ProdlineList(1, 2);
    })


    // 搜索提交
    form.on('submit(demo-table-search)', function (data) {
        ProdlineList(pageIndex, pageSize);
        return false; // 阻止默认 form 跳转
    });

    //物料信息 显示
    function ProdlineList(pageIndex, pageSize) {
        console.log(pageIndex, pageSize);
        // console.log(info);
        $.post({
            url: '@ViewBag.FoundationWrite' + '/api/ProductType/ProdlinesLists',
            //url: "http://localhost:5292/api/ProductType/ProdlinesLists",
            data: JSON.stringify({
                pageIndex: pageIndex,
                pageSize: pageSize,
                pickingNode: $("#pickingNode").val(),
            }),
            async: false,
            dataType: "json",
            contentType: "application/json",
            success: res => {
                
                var cont = ""; //定义变量
                console.log(res.data);
                $.each(res.data, function () {
                    cont += `<tr>
                        <td><span style="color:#1e9fff"><b>${this.productManageNode}</b></span></td>
                        <td>${this.productManageName}</td>
                        <td>${this.productManageNumber}</td>
                        <td>${this.unites}</td>
                        <td>${this.prodeCount}</td>
                        <td>${this.prodLot}</td>
                        <td>${this.stashId}</td>
                        <td>${this.remarks}</td>
                    </tr>`
                })
                $("tbody").html(cont);
                console.log(res);
                // console.log(996, pageSize, pageIndex, res)
                // 完整显示
                laypage.render({
                    elem: 'demo-laypage-all', // 元素 id
                    count: res.totalCount, // 数据总数
                    curr: pageIndex,//当前页
                    limit: pageSize,//每页几条
                    limits: [1, 2, 3],
                    layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip'], // 功能布局
                    jump: function (obj, first) {
                        console.log(obj.curr);
                        console.log(obj.limit);
                        if (!first) {

                            ProdlineList(obj.curr, obj.limit);
                        }
                    }
                });
            }
        });
    };
</script>